/**
 * Created by Administrator on 2017/3/21.
 */
import React, {Component} from 'react';
import {Form, Input, Radio, Select, InputNumber, TreeSelect, Switch} from 'antd';
import {connect} from 'dva';
import find from 'lodash/find'
const FormItem = Form.Item;

import request from '@/utils/request';
class AddPoliciesForm extends Component {
  constructor(props) {
    super(props);
    this.state = {
    };
  }
  componentDidMount() {
    const that=this;

  }
  render() {
    const formItemLayoutWithLabel2 = {
      labelCol: {
        xs: {span: 24},
        sm: {span: 7},
      },
      wrapperCol: {
        xs: {span: 24},
        sm: {span: 14},
      }
    };
    const {getFieldDecorator} = this.props.form;
    let initValue=this.props.editRecord.consumption_abnormality_value
    const that=this
    return (
      <div>
        <Form >
          <FormItem label={'水表号'}  {...formItemLayoutWithLabel2}>
            {getFieldDecorator('meter_number',{
              initialValue: this.props.editRecord.number
            })(
              <Input disabled />
            )}
          </FormItem>
          <FormItem
            {...formItemLayoutWithLabel2}
            label={(
              <span>
               是否报警
            </span>
            )}
          >
            {getFieldDecorator('consumption_abnormality_enable', {
              initialValue: (this.props.editRecord&&this.props.editRecord.consumption_abnormality_enable) ? this.props.editRecord.consumption_abnormality_enable.toString(): '-1',
              rules: [{required: true, message:'报不能为空'}],
            })(
              <Select  style={{width:'100%'}}>
                {[{key:'-1',value:'不报警'},
                  {key:'1',value:'报警'},
                ].map(function(item,index) {
                  return <Option key={index} value={item.key}>
                    {item.value}
                  </Option>
                })}
              </Select>
            )}
          </FormItem>
          <FormItem
            {...formItemLayoutWithLabel2}
            label={(
              <span>
                报警值
                  </span>
            )}
          >
            {getFieldDecorator('value', {
              initialValue: initValue,
              rules: [{required: true, message:'报警值不能为空'}],
            })(
              <InputNumber min={0} style={{width:'100%'}} addonAfter="m³"/>
            )}
          </FormItem>
        </Form>
      </div>
    );
  }
}

const AddPoliciesFormWrap = Form.create()(AddPoliciesForm);
export default connect()(AddPoliciesFormWrap);
